<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>

<script type="text/javascript">
	var edit_form_panel = Ext.create("Ext.form.Panel", {
		url : "edit.htm",
		buttonAlign : "center",
		bodyStyle : "padding: 10px;",
		defaultType : "textfield",
		items : [ {
			fieldLabel : "标题",
			name : "art.title",
			xtype : "textfield",
			anchor : '80%',
			allowBlank : false
		},{
			xtype : 'combo',
			minChars : 1,
			fieldLabel : "银行",
			labelStyle : "text-align:right;",labelWidth : 60,
			name : "art.bank_id",
			emptyText : '请选择银行',
			store : comboxStore,
			displayField : 'name',
			valueField : 'kid',
			hiddenlabelStyle : "text-align:right;",labelWidth : 60,
			name : 'art.bank_id',
			typeAhead : true,
			mode : 'remote',
			queryParam : 'srh_name',
			triggerAction : 'all',
			selectOnFocus : true,
			forceSelection : true,
			allowBlank : false
		},{
			xtype : "ueditor",
			fieldLabel : "内容",
			name : "art.content",
			width : 800,
			height : 300
		}, {
			name : "art.kid",
			hidden : true
		} ],
		buttons : [ {
			text : "保存",
			formBind : true, //only enabled once the form is valid
			disabled : true,
			handler : function() {
				var form = this.up("form").getForm();
				if (form.isValid()) {
					form.submit({
						waitMsg : "保存中...",
						success : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
							edit_form_panel_win.close();
							dataStore.load();
						},
						failure : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
						}
					});
				}
			}
		} ]
	});

	var edit_form_panel_win = Ext.create("Ext.Window", {
		title : "文章编辑",
		closeAction : "hide",
		items : edit_form_panel
	});

	function myEdit(kid) {
		Ext.Ajax.request({
			url : "edit_form.htm?kid=" + kid,
			success : function(response) {
				var json = Ext.util.JSON.decode(response.responseText);
				edit_form_panel.getForm().reset();
				edit_form_panel.getForm().setValues(json);
				edit_form_panel_win.show();
			},
			failure : function(response) {
				Ext.Msg.alert("提示", "操作失败!");
			}
		});
	}//#myEdit
</script>
